package com.crealth.model;

import java.io.Serializable;

import com.alibaba.fastjson.JSONObject;

public class ConsumerCreditCardModel implements Serializable {
	private static final long serialVersionUID = 1640125L;
	
	private int id;
	private int consumerID;
	private String creditCardBank;
	private String creditCardLimit;
	private String creditCardUsed;
	
	public ConsumerCreditCardModel() {
		consumerID = -1;
		creditCardBank = "";
		creditCardLimit = "";
		creditCardUsed = "";
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public int getConsumerID() {
		return consumerID;
	}
	public void setConsumerID(int consumerID) {
		this.consumerID = consumerID;
	}
	public String getCreditCardBank() {
		return creditCardBank;
	}
	public void setCreditCardBank(String creditCardBank) {
		this.creditCardBank = creditCardBank;
	}
	public String getCreditCardLimit() {
		return creditCardLimit;
	}
	public void setCreditCardLimit(String creditCardLimit) {
		this.creditCardLimit = creditCardLimit;
	}
	public String getCreditCardUsed() {
		return creditCardUsed;
	}
	public void setCreditCardUsed(String creditCardUsed) {
		this.creditCardUsed = creditCardUsed;
	}
	
	public void parseFromJson(JSONObject jsonData) {
		if (jsonData.containsKey("creditCardBank")) {
			this.creditCardBank = jsonData.getString("creditCardBank");
		}
		if (jsonData.containsKey("limitMoney")) {
			this.creditCardLimit = jsonData.getString("limitMoney");
		}
		if (jsonData.containsKey("useMoney")) {
			this.creditCardUsed = jsonData.getString("useMoney");
		}
	}
	
	public JSONObject toJSONObject() {
		JSONObject jsonObj = new JSONObject();
		if (creditCardBank != null && creditCardBank.length() >= 0) {
			jsonObj.put("creditCardBank", creditCardBank);
		}
		if (creditCardLimit != null && creditCardLimit.length() > 0) {
			jsonObj.put("limitMoney", creditCardLimit);
		}
		if (creditCardUsed != null && creditCardUsed.length() > 0) {
			jsonObj.put("useMoney", creditCardUsed);
		}
		
		return jsonObj;
	}

}
